package com.justrun.zjutsystem.zjutsystem.utils;

import com.alibaba.excel.EasyExcel;
import com.justrun.zjutsystem.zjutsystem.entity.Teacher;
import com.justrun.zjutsystem.zjutsystem.listener.DemoDataListener;
import com.justrun.zjutsystem.zjutsystem.listener.ExcetListener;
import com.justrun.zjutsystem.zjutsystem.mapper.TeacherMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author ln
 * @Description: ${todo}
 * @date 2020/10/13
 */
public class ExcelUtil {


    /**
     * 导出数据库中的数据到本地
     * @param fileName
     * @param tClass
     * @param sheetName
     * @param data
     * @param <T>
     */
    public  static <T> void exportTeacher(String fileName,Class tClass,String sheetName,List<T> data) {
        EasyExcel.write(fileName,tClass).sheet(sheetName).doWrite(data);

    }

    public static void readExcel(String fileName, ExcetListener excetListener, Class tClass){
        EasyExcel.read(fileName,tClass,excetListener).sheet().doRead();
    }


}
